package com.kelp.codetoolkit.ui.form

import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.ComboBox
import com.intellij.ui.Gray
import com.intellij.ui.JBColor
import java.awt.Color
import java.awt.FlowLayout
import javax.swing.BorderFactory
import javax.swing.DefaultComboBoxModel
import javax.swing.JLabel
import javax.swing.JPanel
import javax.swing.border.LineBorder

/**
 * @author: liuyuebai
 * @date: 2025/1/25 20:19
 * @description:
 */
class XmlMethodPanel(project: Project):JPanel() {

    private val xmlSelectArray = arrayOf("Select XML Method","select", "update", "delete")
    private val xmlSelectModel: DefaultComboBoxModel<String> = DefaultComboBoxModel(xmlSelectArray)
    private val xmlSelectLabel: JLabel = JLabel("SQL XML Method：")
    private val xmlSelectContent: ComboBox<String> = ComboBox(xmlSelectModel)
    private val xmlSelectPanel = JPanel(FlowLayout(FlowLayout.LEFT))
    init {

    }

    fun getXmlPanel(): JPanel {
        // 创建一个新面板用于添加methodName到第二行
        xmlSelectPanel.add(xmlSelectLabel)
        xmlSelectPanel.add(xmlSelectContent)
        // 定义浅灰色
        val lightGray = JBColor.GRAY
        // 创建宽度为 1 像素、颜色为浅灰色的 LineBorder
        val lineBorder = LineBorder(lightGray, 1)
        // 创建带有标题的边框，使用上面创建的 LineBorder 作为边框
        val titledBorder = BorderFactory.createTitledBorder(lineBorder, "SQL XML Method")
        xmlSelectPanel.setBorder(titledBorder)
        return xmlSelectPanel
    }

    fun getXmlMethod():String{
        return xmlSelectContent.selectedItem as String
    }
}